package com.chainyoung.component_tmperson.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.entity.BookMark;

import java.util.List;

public class BookmarkListAdapter extends BaseQuickAdapter<BookMark,BaseViewHolder> {

    private View.OnClickListener onClickListener;
    private View.OnLongClickListener onLongClickListener;

    public BookmarkListAdapter(@Nullable List<BookMark> data) {
        super(R.layout.layout_browser_collection_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BookMark item) {

        helper.setText(R.id.tv_title,item.getTitle());
        helper.setText(R.id.tv_url,item.getUrl());
        //((ImageView)helper.getView(R.id.iv_collect)).setImageResource(item.isCollected()?R.mipmap.ic_browser_collected:R.mipmap.ic_browser_collect_no);
       // helper.getView(R.id.iv_collect).setOnClickListener(onClickListener);
       // helper.getView(R.id.iv_collect).setTag(helper.getAdapterPosition());
        helper.getView(R.id.rl_bookmark).setOnClickListener(onClickListener);
        helper.getView(R.id.rl_bookmark).setOnLongClickListener(onLongClickListener);
        helper.getView(R.id.rl_bookmark).setTag(helper.getAdapterPosition());


    }

    public View.OnClickListener getOnClickListener() {
        return onClickListener;
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
        this.onLongClickListener = onLongClickListener;
    }
}
